import {Action, createAction} from "redux-actions";
import {call, put} from "redux-saga/effects";
import {getHospital} from "../../../utils/RequestUtils";
import {HOSPITAL_LIST, HOSPITAL_LIST_FETCH} from "../../types";
// 获取科室列表
export const hospitalList = createAction(HOSPITAL_LIST, (data: []) => {
    return {data};
});
export const hospitalListFetch = createAction(HOSPITAL_LIST_FETCH, (options: object) => {
    return {...options};
});

export function* requestHospitalList(options:Action<any>) {
    yield put(hospitalList([]));
    const fetchedData = yield call(getHospital, options.payload);
    yield put(hospitalList(fetchedData.data));
}
